<?php
include_once 'Element.php';


class Container extends Element {

    private $elements;

    public function __construct($id) {
        parent::__construct($id);
    }

    public function generate() {

        $html = array();
        $id = $this->getId();

        $html[] = "<div id='$id'>";

        if ($this->elements) {
            foreach ($this->elements as $value) {
                $html[] = $value->generate();
            }
        }

        $html[] = "</div>";

        $output = '';
        foreach ($html as $code) {
            $output = $output . $code;
        }
        return $output;
    }

    public function addElement(Element $element) {
        $this->elements[] = $element;
    }

}

?>
